<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Hao\ORMJsonRelation\HasORMJsonRelations;
use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property string $title 方案名称
 * @property array $robot_ids 生效企微号
 * @property array $include_tag 触发智能标签配置
 * @property array $exclude_tag 排除智能标签配置
 * @property array $content 发送内容
 * @property int $status 状态：0=禁用 1=启用
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 */
class ChSmartAutoPush extends MineModel
{
    //https://github.com/limingxinleo/hyperf-orm-json-relation
    use HasORMJsonRelations;


    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_smart_auto_push';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'title', 'robot_ids', 'include_tag', 'exclude_tag', 'content', 'status', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'robot_ids' => 'array', 'include_tag' => 'array', 'exclude_tag' => 'array', 'content' => 'array', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];


    public function robotList()
    {
        return $this->hasManyInJsonArray(ChRobot::class,'id','robot_ids');
    }
}
